package com.example.poc.security;

import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

import com.example.poc.user.UserRepository;

@Component
public class SecurityUserDetailService implements UserDetailsService {

  private final UserRepository _userRepository;

  public SecurityUserDetailService(UserRepository userRepository) {
    this._userRepository = userRepository;
  }

  @Override
  public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
    return _userRepository.findUserByUsername(username);
  }
}